<#include "common.ftl">
ALTER TABLE ${tableName}
<#-- 创建外键 -->
<#if foreignList?? && foreignList?size gt 0>
    <#list foreignList as fk>
        ${'\t'}ADD CONSTRAINT `${sanitize(fk.foreignKeyName)}` FOREIGN KEY (${sanitize(fk.fields)})<#t>
        REFERENCES ${sanitize(fk.referenceTableName)} (${sanitize(fk.referenceFieldName)})<#t>
        <#if fk.whenDelete??> ON DELETE ${fk.whenDelete}</#if><#t>
        <#if fk.whenUpdate??> ON UPDATE ${fk.whenUpdate}</#if><#t>
        <#if fk_has_next>,<#else >;<#t></#if>
    </#list>
</#if>
